import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const state = {
    publicWidth: null,
    publicHeight: null,
    viewAreaHeight: null,
    tableMaxHeight: null,
    breadcrumbData: ['首页', '站点设置'],
    activeIndex: '2',
    userName: sessionStorage.getItem("userName")
}

const getters = {
    doneRefreshTable: state => {
        return state.refreshTable++
    }
}

const mutations = {
    increment(state, datas) {
        state.publicWidth = datas
    },
    LogonAuthority(state, datas) {
        state.LogonAuthority = datas
    },
    heightH(state, datas) {
        state.publicHeight = datas
    },
    viewAreaHeightMethods(state, data) {
        state.viewAreaHeight = data
    },
    breadcrumbDataMethod(state, datas) {
        state.breadcrumbData = datas
    },
    activeIndexMethod(state, datas) {
        state.activeIndex = datas
    },
    tableMaxHeightMethod(state, datas) {
        state.tableMaxHeight = datas
    }
}
const actions = {
    // 公共宽度
    publicWidth({
        commit
    }, data) {
        commit('increment', data)
    },
    // 公共高度
    publicHeight({
        commit
    }, data) {
        commit('heightH', data)
    },
    // 视图可见区域
    viewAreaHeightAction({
        commit
    }, data) {
        commit('viewAreaHeightMethods', data)
    },
    breadcrumbDataAction({
        commit
    }, data) {
        commit('breadcrumbDataMethod', data)
    },
    activeIndexAction({
        commit
    }, data) {
        commit('activeIndexMethod', data)
    },
    tableMaxHeightAction({
        commit
    }, data) {
        commit('tableMaxHeightMethod', data)
    },
}

export default new Vuex.Store({
    state,
    getters,
    mutations,
    actions
})
